<template>
  <div id="LeftList">
    <h2 class="fix">网站公告<a href="#/notice-list" class="flo-right">更多</a></h2>
    <ul>
      <li class="fix cup" v-for="item in noticeList" @click="onNoticeClick(item.id)">
        <span class="flo-left db text-ovh">{{item.title}}</span>
        <span class="flo-right db">{{item.createTime | timeFilter}}</span>
      </li>
    </ul>
    <h2 class="fix help">帮助中心<a href="#/helpcenter" class="flo-right">更多</a></h2>
    <ul>
      <li class="fix cup" v-for="(item,index) in helpList" @click="onHelpClick(index)">
        <span class="flo-left db text-ovh">{{item.title}}</span>
      </li>
    </ul>
  </div>
</template>
<script type="text/javascript">
export default {
  data() {
    return {
      noticeList: [],
      helpList: []
    }
  },
  methods: {
    onNoticeClick(id) {
      this.$router.push('/notice-text?id=' + id)
    },
    onHelpClick(page) {
      this.$router.push('/helpcenter?page=' + page)
    }
  },
  mounted() {
    this.$http.get('/sysContent/list', {
      params: {
        type: 2,
        page: 1,
        rows: 6
      }
    }).then(data => {
      if (data.data.httpCode === 200) {
        this.noticeList = data.data.rows
      } else {
        console.log(data.data.msg)
        this.$toasted.show(data.data.msg)
      }
    }).catch(err => {
      console.log(err)
    })
    this.$http.get('/sysContent/list', {
      params: {
        type: 3,
        page: 1,
        rows: 6
      }
    }).then(data => {
      if (data.data.httpCode === 200) {
        this.helpList = data.data.rows
      } else {
        console.log(data.data.msg)
        this.$toasted.show(data.data.msg)
      }
    }).catch(err => {
      console.log(err)
    })
  },
  filters: {
    timeFilter(s) {
      return s.split(' ')[0]
    }
  }
}

</script>
<style type="text/css" scoped>
.news-list-right h2 {
  border-left: 3px solid #e60012;
  padding-left: 15px;
  line-height: 20px;
  margin-top: 40px;
  color: #e60012;
}

.news-list-right h2.help {
  border-color: #01378c;
  color: #01378c;
}

.news-list-right h2 a {
  font-size: 14px;
  color: #909090;
}

.news-list-right ul li {
  line-height: 35px;
  color: #7e7e7e;
}

.news-list-right ul {
  margin-top: 24px;
}

.news-list-right ul li a {
  width: 180px;
  color: #7e7e7e;
}

.news-list-right ul li a:hover {
  color: #3f5d9c;
}

</style>
